/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tesam.gedeon.controller;

import com.tesam.gedeon.entity.Account;
import com.tesam.gedeon.entity.SystemUser;
import com.tesam.gedeon.service.AccountService;
import com.tesam.gedeon.service.UserService;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Sistema
 */
@Controller
public class UserController {
    
    @Autowired
    SystemUserController system ;
    @Autowired
    UserService userService;
    @Autowired
    AccountService accountService;        
    Account account = new Account();
    
    @RequestMapping(value = "/user/profile")
    public ModelAndView profile(@ModelAttribute("SystemUser")SystemUser user,HttpServletRequest request){
        ModelAndView mv = new ModelAndView("/user/profile");
        
        system.loadDataSystem(mv, request);
        
        account.setOwnerId(user.getId());
        
        mv.addObject("account", accountService.getListByOwner(account));
        
        mv.addObject("user", userService.getProfileById(user));
        
        return mv;
    
    }
    
}
